package com.x.reader.service;

import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import com.x.reader.dao.UserDao;
import com.x.reader.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserService extends BaseService {

    @Autowired
    private UserDao userDao;

    public User insertUser(User user) {
        try {
            return this.insert(user);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public void updateUser(User user) {
        try {
            this.update(user);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public List<User> selectUserList(User user) {
        try {
            return userDao.selectUserList(user);
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

}
